# -*- coding: utf-8 -*-

# Scrapy settings for zongheng project
#
# For simplicity, this file contains only settings considered important or
# commonly used. You can find more settings consulting the documentation:
#
#     https://docs.scrapy.org/en/latest/topics/settings.html
#     https://docs.scrapy.org/en/latest/topics/downloader-middleware.html
#     https://docs.scrapy.org/en/latest/topics/spider-middleware.html

BOT_NAME = 'zongheng'

SPIDER_MODULES = ['zongheng.spiders'] # 爬虫模块
NEWSPIDER_MODULE = 'zongheng.spiders' # 使用genspider命令创建的spider模块

# Crawl responsibly by identifying yourself (and your website) on the user-agent
# USER_AGENT = 'zongheng (+http://www.yourdomain.com)' 默认的user_agent

# Obey robots.txt rules
ROBOTSTXT_OBEY = False #机器人协议

# Configure maximum concurrent requests performed by Scrapy (default: 16) 并发请求的最大值
# CONCURRENT_REQUESTS = 32

# Configure a delay for requests for the same website (default: 0) #设置相同网站你请求延迟
# See https://docs.scrapy.org/en/latest/topics/settings.html#download-delay
# See also autothrottle settings and docs
# DOWNLOAD_DELAY = 3
# The download delay setting will honor only one of:  #相同的延迟设置智能生效一个
# CONCURRENT_REQUESTS_PER_DOMAIN = 16 # 单个域名的并发请求 一个域名可能有多个ip
# CONCURRENT_REQUESTS_PER_IP = 16  # 单个ip的并发请求

# Disable cookies (enabled by default) # 设置是否使用cookie
# COOKIES_ENABLED = False

# Disable Telnet Console (enabled by default) # 设置是否使用监控控制台
# TELNETCONSOLE_ENABLED = False

# Override the default request headers:
DEFAULT_REQUEST_HEADERS = {
  'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
  'Accept-Language': 'en',
  'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:74.0) Gecko/20100101 Firefox/74.0',
}

# Enable or disable spider middlewares  #设置爬虫中间件
# See https://docs.scrapy.org/en/latest/topics/spider-middleware.html
# SPIDER_MIDDLEWARES = {
#    'zongheng.middlewares.ZonghengSpiderMiddleware': 543,
# }

# Enable or disable downloader middlewares   # 设置下载中间件
# See https://docs.scrapy.org/en/latest/topics/downloader-middleware.html
# DOWNLOADER_MIDDLEWARES = {
#    'zongheng.middlewares.ZonghengDownloaderMiddleware': 543,
# }

# Enable or disable extensions    # 是否启用扩展程序   控制台
# See https://docs.scrapy.org/en/latest/topics/extensions.html
# EXTENSIONS = {
#    'scrapy.extensions.telnet.TelnetConsole': None,
# }

# Configure item pipelines     # 设置管道 优先级可以是0~1000
# See https://docs.scrapy.org/en/latest/topics/item-pipeline.html
ITEM_PIPELINES = {
    'zongheng.pipelines.ZonghengPipeline': 100,
    'zongheng.pipelines.ContentPipeline': 300
}


# 启用和配置AutoThrottle扩展程序
# Enable and configure the AutoThrottle extension (disabled by default)
# See https://docs.scrapy.org/en/latest/topics/autothrottle.html
# AUTOTHROTTLE_ENABLED = True
# The initial download delay # 初始下载延迟
# AUTOTHROTTLE_START_DELAY = 5

# The maximum download delay to be set in case of high latencies   # 在高延迟的情况下设置最大下载延迟
# AUTOTHROTTLE_MAX_DELAY = 60

# The average number of requests Scrapy should be sending in parallel to  # 设置框架发送并行给远程服务器请求的平均次数
# each remote server
# AUTOTHROTTLE_TARGET_CONCURRENCY = 1.0

# Enable showing throttling stats for every response received:   # 启动配置默认缓存
# AUTOTHROTTLE_DEBUG = False

# Enable and configure HTTP caching (disabled by default)
# See https://docs.scrapy.org/en/latest/topics/downloader-middleware.html#httpcache-middleware-settings
# HTTPCACHE_ENABLED = True
# HTTPCACHE_EXPIRATION_SECS = 0
# HTTPCACHE_DIR = 'httpcache'
# HTTPCACHE_IGNORE_HTTP_CODES = []
# HTTPCACHE_STORAGE = 'scrapy.extensions.httpcache.FilesystemCacheStorage'


# 日志
# LOG_FILE = "1.log"  # 写入日志文件
LOG_ENABLED = True  # Ture表示日志输出到控制台   False  日志不输出到控制台
LOG_ENCODING = "utf-8"
LOG_FORMAT = "%(asctime)s [%(name)s] %(levelname)s: %(message)s"
LOG_DATEFORMAT = "%Y%m%d %H:%M:%S"
LOG_LEVEL = "ERROR"
# DEBUG（调试信息）< INFO（一般信息） < WARNNING（警告信息） < ERROR（一般错误） < CRITICAL（严重错误）
